<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/jquery-3.2.1.js"></script>
    <style>
        .content{
            text-align: center;
            width:400px;
            margin: 100px auto;
            position: relative;
        }                 
        
        .bg{
            border-radius: 50%;
            animation: animate 2s linear infinite;
            animation-play-state: paused;
            
        }
        .play-btn{
            width: 100px;
        }
        @keyframes animate{
            0%{
                transform: rotate(0deg);
            }
            100%{
                transform: rotate(360deg);
            }
        }
        .item{
            width: 110px;
            position: absolute;
            z-index: 100;
            top: -64px;
            left: 229px;
            transform: rotate(-40deg);
            transform-origin: 30px 30px;
            /* animation-fill-mode:forwards|backwards  动画停止的位置*/
            /* transform-origin: 26.6% 16.8%; */
        }
        .play-music{
            animation: play 1s linear;
            animation-fill-mode:forwards;
        }
        .pause-music{
            animation: pause 1s linear;
            animation-fill-mode:forwards;
        }
        @keyframes play {
            0%{
                transform: rotate(-40deg);
            }
            100%{
                transform: rotate(0deg);
            }
        }
        @keyframes pause {
            0%{
                transform: rotate(0deg);
            }
            100%{
                transform: rotate(-40deg);
            }
        }
    </style>
</head>
<body>
    <div class="content">
        <img class="item" src="./images/play-item.png">
        <img class="bg" src="./images/bg.png">
        <img class="play-btn" src="images/pause.png">
    </div>
    <script>
        // isPlay 表示播放的状态
        var isPlay=false;
        $(".play-btn").click(function(){
            if(isPlay){
                isPlay=false
                // $(element).attr(key,value)  改变元素属性值
                $(this).attr("src","images/pause.png")
                $(".bg").css({"animationPlayState":"paused"})
                // $(".item").css({"transform":"rotate(0deg)"})
                $(".item").addClass("pause-music").removeClass("play-music")
            }else{
                isPlay=true;
                $(this).attr("src","images/play.png")
                $(".bg").css({"animationPlayState":"running"})
                // $(".item").css({"transform":"rotate(60deg)"})
                $(".item").addClass("play-music").removeClass("pause-music")
            }
            console.log(isPlay)
        })
    </script>
</body>
</html>